home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-06-18 | 2.7 KB | 121 lines | [TEXT/dosa] |
- // DesktopImage.java : this is a Java source code file for the program Facade.
- // Copyright 1998, Andrew S. Downs
- // andrew.downs@tulane.edu
- //
- // This source code is distributed as freeware.
- // Just keep this author information in the file. Enjoy!
-
- import java.awt.*;
- import java.awt.event.*;
- import java.awt.image.*;
- import java.io.*;
- import java.util.*;
-
- public class DesktopImage extends DesktopComponent implements Serializable /*, MouseListener, MouseMotionListener */ {
- boolean drag = false;
-
- int initialX = 0;
- int initialY = 0;
-
- transient Image theImage;
- Point labelLocation;
- String path;
-
- DesktopImage() {
- super();
- // this.addMouseListener( this );
- // this.addMouseMotionListener( this );
- }
-
- public void setImage( Image i ) {
- this.theImage = i;
- }
-
- public Image getImage() {
- return this.theImage;
- }
-
- public void setPath( String s ) {
- this.path = s;
- }
-
- public String getPath() {
- return this.path;
- }
-
- public void setLabelLocation( Point p ) {
- this.labelLocation = p;
- }
-
- public void setLabelLocation( int x, int y ) {
- this.labelLocation = new Point( x, y );
- }
-
- public Point getLabelLocation() {
- return this.labelLocation;
- }
-
- private void writeObject( ObjectOutputStream s ) throws IOException {
- s.defaultWriteObject();
- }
-
- private void readObject( ObjectInputStream s ) throws ClassNotFoundException, IOException {
- s.defaultReadObject();
- }
- /*
- public void mouseClicked( MouseEvent e ) {
- if ( e.getClickCount() == 1 ) {
- }
- else if ( e.getClickCount() == 2 ) {
- if ( Desktop.windowExists( this.getPath() ) ) {
- // Desktop.setTopFrame( this.getPath() );
- System.out.println( "DEBUG: setting top frame from DImage..." );
- }
- else {
- DesktopFrame dw = new DesktopFrame( this.getPath() );
- // DesktopFrame dw = new DesktopFrame();
- // dw.setBounds( 100, 100, 200, 200 );
- dw.setLabel( this.getLabel() );
- dw.setPath( this.getPath() );
- dw.pack();
- dw.validate();
- dw.show();
- dw.toFront();
- dw.repaint();
- }
- }
- }
-
-
- public void mouseDragged( MouseEvent e ) {
- if ( this.drag ) {
- // Desktop.adjustClipRect( this.getBounds() );
- this.setLocation( this.getBounds().x - this.initialX + e.getX(), this.getBounds().y - this.initialY + e.getY() );
- repaint();
- }
- }
-
- public void mouseMoved( MouseEvent e ) {
- }
-
- public void mouseEntered( MouseEvent e ) {
- }
-
- public void mouseExited( MouseEvent e ) {
- }
-
- public void mousePressed( MouseEvent e ) {
- this.initialX = e.getX();
- this.initialY = e.getY();
- this.drag = true;
- }
-
- public void mouseReleased( MouseEvent e ) {
- this.initialX = 0;
- this.initialY = 0;
- this.drag = false;
- }
- */
- }
-
-